Skip to content

fix: show image output price for AI Gateway image models - #6910

Merged
andrelandgraf merged 1 commit into
mainfrom
aileen/aileen/neon-dx/task/task-2026-11-20t20-35-18-844z/cli-run-2026-11-20t20-35-18-844z
Nov 21, 2026
Merged

andrelandgraf merged 1 commit into
mainfrom
aileen/aileen/neon-dx/task/task-2026-11-20t20-35-18-844z/cli-run-2026-11-20t20-35-18-844z

Conversation

@andrelandgraf

Copy link
Copy Markdown
Member

This PR comes from a request from Andre.

Problem

gemini-3-pro-image and gemini-3-1-flash-image bill image output tokens at a separate rate. The gateway's GET /v1/models carries that rate, but neon.com publishes only the text output rate:

// GET /v1/models, gemini-3-pro-image
"pricing": { "prompt": "0.000002", "completion": "0.000012", "image_output": "0.00012" }

// neon.com/models.json today
"cost": { "input": 2, "output": 12 }

The build-time refresh (scripts/lib/ai-gateway-models.mjs) maps only prompt, completion, and the cache rates, so image_output is dropped. The model table on /ai-gateway#models and /docs/ai-gateway/overview, the per-model docs pages, and the llms markdown mirror then show $12/M for Gemini 3 Pro Image, while image output costs $120/M. Gemini 3.1 Flash Image shows $3/M; its image output costs $60/M.

No other listed model has image_output. GPT-6.1 Terra and Gemini 4 Carbon list output_modalities: ["text"].

Solution

The fix belongs in the catalog pipeline and the shared row builder, so every surface that reads /models.json gets it:

  • toCost() maps pricing.image_output to a new cost.output_image key, in USD per 1M tokens. validateCatalog accepts the key. Without that, the refresh would reject the catalog and keep the committed file.
  • models.dev's Cost schema is strict and has no image rate, so output_image exists only on neon.com. classifyDrift leaves it out of the models.dev mirror comparison, so the scheduled mirror check doesn't report a difference that models.dev can never close.
  • toRow() adds costOutputImageLabel, which is null for models without an image rate. All three renderers read it:
Surface Text-only model Image model
Table Output /M cell $12 $12, then image $120 on a second, smaller line
llms markdown table $12 $12 (image $120)
/docs/ai-gateway/models/<id> Output /M section an extra Image output /M section after Output /M

The second line wraps inside the existing Output /M column. Column widths are unchanged, so text-only rows lay out the same as before. Sorting by Output /M still uses the text rate.

The committed data.json is unchanged. The build refresh writes the new key on the next production or preview build.

Verification

  • npm run test:unit:run -- --retry=2 --maxWorkers=4 --testTimeout=30000 --hookTimeout=60000: 115 files and 1543 tests pass. New tests cover the mapper, the validator (it rejects a string or negative output_image), the drift exclusion, row labels, the table cell, the markdown cell, and the detail page sections. The existing text-only assertions are unchanged and still pass.
  • ESLint and Prettier pass on the changed files. node scripts/verify-agent-endpoints.mjs passes 13/13 endpoints and 68/68 checks. npm run check:models-sync exits 0.
  • End to end against a real gateway, using a throwaway project in a test org that has since been deleted:
    • scripts/update-models-from-ai-gateway.mjs wrote {"input":2,"output":12,"output_image":120} for gemini-3-pro-image and {"input":0.5,"output":3,"output_image":60} for gemini-3-1-flash-image. No other model changed, compared with a refresh on unchanged code.
    • With that data, next dev served /models.json with the new key, and the regenerated .md page for gemini-3-pro-image has ## Image output /M with $120.
  • Screenshots: before and after, filtered to ?q=gemini-3, for the landing table (dark, desktop and mobile), the docs table (light and dark, desktop and mobile), and the Gemini 3 Pro Image detail page (light and dark). After the change, both image models show image $60 and image $120 under the text price, and the detail page has an Image output /M section. The text-only rows above the first image model are pixel-identical before and after in the landing and docs desktop captures. The browser console showed no errors.

Left open

  • The task described a default "Latest" view that hides new models. Neither this repo nor the live neon.com HTML has such a view. The table's default is the All tab, sorted by release date, newest first, and all three new ids render there. Gemini 3 Pro Image sorts far down because its release_date is 2025-11-20. The models do not appear under the Image tab. That tab filters on measured imageGeneration in src/app/models/capabilities.json, which has no records for gemini-3-pro-image, gemini-3-1-flash-image, or gpt-6-1-terra. Those records come from the conformance probe in neondatabase/neon-console-code-examples. Until they exist, these models also have no verified endpoints or code examples on their detail pages, and /models omits them.
  • Routes: capabilities.json has no route data for the two image models, so the page states that no verified endpoints are available. The gateway listing's dialects field for both is ["chat_completions", "gemini_generate_content"]. The route docs stay unchanged until the probe measures image output on each route. Gemini 4 Carbon's measured routes (chat completions with array content, plus the native Gemini route) are already in the docs.
  • Gemini Nano Banana 2.1 is not in the gateway listing or on neon.com.
  • When the image models are added to the models.dev neon provider, leave output_image out of [cost], because models.dev's schema rejects it. The add-model-to-ai-gateway skill says to copy [cost] from the website entry; it needs a note about this exception. Orbit's catalog-mirror job compares cost separately from this repo and will report the extra key as a difference unless it also ignores it.

Review media

after-detail-dark.png

after-detail-light.png

after-docs-desktop-dark.png

after-docs-desktop-light.png

after-docs-mobile-dark.png

after-docs-mobile-light.png

after-landing-desktop.png

after-landing-mobile.png

before-detail-dark.png

before-detail-light.png

before-docs-desktop-dark.png

before-docs-desktop-light.png

before-docs-mobile-dark.png

before-docs-mobile-light.png

before-landing-desktop.png

before-landing-mobile.png


Opened by Aileen job aileen/neon-dx/task/task-2026-11-20t20-35-18-844z/cli-run-2026-11-20t20-35-18-844z (factory neon-dx).
Next: Aileen's reviewer classifies and reviews this PR; the factory policy decides whether it merges without Andre.

Task:

Fix how the AI Gateway model catalog shows models that bill image output separately, on neon.com/models and the AI Gateway docs model table.

Context: the AI Gateway now serves models that produce images (GPT-6.1 Terra, Gemini 3 Pro Image, Gemini 3.1 Flash Image, Gemini Nano Banana 2.1, Gemini 4 Carbon). Their image output is billed as its own token type at a different price from text output. Billing is correct; the catalog display is not:

  1. Dual pricing: these models have a text output price and an image output price, but the UI shows only the cheaper text price, which understates what an image request costs. Show the image output price alongside the text price (for example its own column or a second line in the price cell), sourced from the same catalog data the page already reads (neon.com/models.json and the gateway's GET /v1/models); do not hardcode prices. If the catalog data does not carry the image price yet, say exactly which field is missing and where it would come from, and add a short note in the docs table that image output is priced separately, linking to the pricing details.
  2. Discovery: the new models only appear after clicking "All models"; under the default "Latest" view they are missing. Find why (sorting, release dates, or the filter) and make newly added models appear under "Latest".
  3. Some of these models work only through the native Gemini API route, not chat completions. Check the page and docs say which route each model needs, using the existing capabilities data.

Verify on the rendered page (light and dark, desktop and mobile) with before/after screenshots, and check that existing text-only models render exactly as before. Follow the add-model-to-ai-gateway skill's rules (never invent prices).

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
neon-next Ready Ready Preview Nov 20, 2026 9:01pm UTC

Request Review

@andrelandgraf andrelandgraf left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aileen review: approve (fix, medium risk, ae536ee)

Verdict

Approve. The PR maps the gateway's pricing.image_output to cost.output_image (USD per 1M tokens) and shows it in the model table, the llms markdown table, and the per-model detail page. The evidence holds against the live gateway.

Verification

  • Live gateway: on a throwaway project in org-old-flower-82714815 (deleted afterwards), GET /v1/models listed 68 models. Only gemini-3-pro-image (image_output: "0.00012") and gemini-3-1-flash-image ("0.00006") carry an image rate, and no overrides entry has one. Running the PR's buildCatalog + validateCatalog on that listing returns no errors and produces {"input":2,"output":12,"output_image":120} and {"input":0.5,"output":3,"output_image":60}. Compared with the live neon.com/models.json, those two cost blocks are the only difference.
  • models.dev's Cost schema is .strict() with no image key, so excluding output_image from classifyDrift is justified. Against the live models.dev neon provider, both image models are currently in awaitingUpstream, so today the exclusion only keeps that list from gaining a false difference later.
  • npm run test:unit:run -- --retry=2 --maxWorkers=4 --testTimeout=30000 --hookTimeout=60000: 115 files and 1543 tests pass, which matches the description. ESLint and prettier --check pass on the 12 changed files.
  • The PR's screenshots show the second image $N line only on the two image models, with text-only rows unchanged, and the detail page shows the Image output /M section.
  • A second-opinion reviewer (Claude Opus 5.5) reported no blocking findings.

Scope

The diff covers one concern: one mapping line, one allowed rate key, one drift exclusion, and three render branches, each with a focused test. data.json is unchanged, and the build refresh adds the key. The task's "Latest" view does not exist in the code or on live neon.com, and the description says so. It also leaves route documentation unchanged because capabilities.json has no measurements for these models. Both are reasonable. No decision in force applies.

Residual risk (why medium)

  • cost.output_image is the first cost key on /models.json that models.dev's schema doesn't define, and route.js says the endpoint can be read by the same code that reads models.dev. A downstream reader that parses cost with models.dev's strict schema (the console model picker is one consumer, and its code isn't available here) would reject these two entries. Readers that ignore unknown keys, and the @neon/ai-sdk-provider drift test, are unaffected.
  • Image rates on context-tier overrides would be dropped, because the tiers are built with rates(). No model has one today.
  • Follow-ups outside this PR, also listed in its description: add a note to the add-model-to-ai-gateway skill to leave output_image out of the models.dev [cost], and have Orbit catalog-mirror ignore the key.

Nits (non-blocking)

  • model-rows.js checks === undefined, while toCost uses != null. An explicit null would render image —, but validateCatalog rejects null, so this can't happen today.
  • On the landing desktop table, image $60 wraps to two lines in the narrow Output /M column.

@andrelandgraf

Copy link
Copy Markdown
Member Author

Waiting for Andre: category fix needs Andre. Merge it when it is ready, or comment to have Aileen change it.

@andrelandgraf
andrelandgraf merged commit 00d8a74 into main Nov 21, 2026
4 checks passed
@andrelandgraf
andrelandgraf deleted the aileen/aileen/neon-dx/task/task-2026-11-20t20-35-18-844z/cli-run-2026-11-20t20-35-18-844z branch November 21, 2026 20:14

This branch was successfully deployed

1 active deployment
Preview – neon-next — ae536eeb Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant